import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/login/login.vue'
import Register from '@/login/register.vue'
import Home from '@/home/home.vue'
import Search from '@/search/search.vue'
import Discripe from '@/book/discripe.vue'
Vue.use(Router)
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location, onResolve, onReject) {

  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)

  return originalPush.call(this, location).catch(err => err)

}
export default new Router({
  mode : 'history',
  routes: [
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
      meta : {
        auth : true
      }
    },
    {
      path: '/search',
      name: 'search',
      component: Search,
      meta : {
        auth : true
      }
    },
    {
      path: '/discripe',
      name: 'discripe',
      component: Discripe,
      meta:{
        auth : true
      }
    },
    {
      path: '/register',
      name: 'register',
      component: Register,
      meta:{
        auth : false
      }
    }
  ]
});
